namespace Hack.Decompiling.PEA.PE
{
  using System;
  using System.IO;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Text;

  /// <summary>
  /// Format of the debugging information. 
  /// This member can be one of the following values. 
  /// </summary>
  public enum DebugType : uint
  {
    /// <summary>
    /// Unknown value, ignored by all tools. 
    /// </summary>
    UNKNOWN = 0,
    /// <summary>
    /// COFF debugging information (line numbers, symbol table, and string table). 
    /// This type of debugging information is also pointed to by fields in the file headers. 
    /// </summary>
    COFF = 1,
    /// <summary>
    /// CodeView debugging information. 
    /// The format of the data block is described by the CodeView 4.0 specification. 
    /// </summary>
    CODEVIEW = 2,
    /// <summary>
    /// Frame pointer omission (FPO) information. 
    /// This information tells the debugger how to interpret nonstandard stack frames, 
    /// which use the EBP register for a purpose other than as a frame pointer. 
    /// </summary>
    FPO = 3,
    /// <summary>
    /// Miscellaneous information. 
    /// </summary>
    MISC = 4,
    /// <summary>
    /// Exception information. 
    /// </summary>
    EXCEPTION = 5,
    /// <summary>
    /// Fixup information.
    /// </summary>
    FIXUP = 6,
    /// <summary>
    /// 
    /// </summary>
    OMAP_TO_SRC = 7,
    /// <summary>
    /// 
    /// </summary>
    OMAP_FROM_SRC = 8,
    /// <summary>
    /// Borland debugging information. 
    /// </summary>
    BORLAND = 9,
    /// <summary>
    /// 
    /// </summary>
    RESERVED10 = 10,
    /// <summary>
    /// 
    /// </summary>
    CLSID = 11,
  }
  /// <summary>
  /// The DebugDirectory structure represents the debug directory format.
  /// </summary>
  public unsafe struct DebugDirectory
  {
    /// <summary>
    /// Reserved. (Always be 0)
    /// </summary>
    public UInt32 Characteristics;
    /// <summary>
    /// Time and date the debugging information was created. 
    /// </summary>
    public UInt32 TimeDateStamp;
    /// <summary>
    /// Major version number of the debugging information format. 
    /// </summary>
    public UInt16 MajorVersion;
    /// <summary>
    /// Minor version number of the debugging information format. 
    /// </summary>
    public UInt16 MinorVersion;
    /// <summary>
    /// Format of the debugging information.
    /// </summary>
    public UInt32 Type;
    /// <summary>
    /// Size of the debugging information, in bytes. This value does not include the debug directory itself. 
    /// </summary>
    public UInt32 SizeOfData;
    /// <summary>
    /// Address of the debugging information when the image is loaded, 
    /// relative to the image base.(RVA)
    /// </summary>
    public UInt32 AddressOfRawData;
    /// <summary>
    /// File pointer to the debugging information. 
    /// </summary>
    public UInt32 PointerToRawData;
  }
  /// <summary>
  /// FPO
  /// </summary>
  public enum FPO
  {
     FRAME_FPO   = 0,
     FRAME_TRAP  =1,
     FRAME_TSS   = 2,
  }
  /// <summary>
  /// FPOAttributes
  /// </summary>
  public enum FPOAttributes:ushort
  {
    //UInt16        cbProlog : 8;          // # bytes in prolog
    //UInt16        cbRegs   : 3;          // # regs saved
    //UInt16        fHasSEH  : 1;          // TRUE if SEH in func
    //UInt16        fUseBP   : 1;          // TRUE if EBP has been allocated
    //UInt16        reserved : 1;          // reserved for future use
    //UInt16        cbFrame  : 2;          // frame type

  }
  /// <summary>
  /// FPOData
  /// </summary>
  public struct FPOData
  {
    public UInt32 ulOffStart;            // offset 1st byte of function code
    public UInt32 cbProcSize;            // # bytes in function
    public UInt32 cdwLocals;             // # bytes in locals/4
    public UInt16 cdwParams;             // # bytes in params/4

  }

  #region Linenumber
  public enum LinenumberType
  {
    FunctionIndex  = 1,
    VirtualAddress = 2,
  }
  public struct LinenumberRecord
  {
    #region Fields
    public UInt32 IndexOrAddress;
    public UInt16 Linenumber;
    #endregion
    #region Properties
    public LinenumberType Type
    {
      get
      {
        return this.Linenumber == 0 ? 
          LinenumberType.FunctionIndex : 
          LinenumberType.VirtualAddress;
      }
    }
    #endregion
  }
  #endregion

}